# -*- codeing = utf-8 -*-
# @Time : 2020/7/22 15:39
# @Author : haos
# @File : testselenium.py
# @Software : PyCharm
import copy
import os
import re
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
import xlwt
import pymongo
import spider

import spider as sp

def main():
    url = "http://www.customs.gov.cn/customs/302249/302274/302277/index.html"
    # url = 'http://www.customs.gov.cn/customs/302249/302274/302277/302276/3017256/index.html'

    driver = sp.get_driver()
    driver.get(url)
    time.sleep(4)
    currency = driver.find_element_by_class_name('tbtj2020_span').find_elements_by_tag_name('span')[1]
    # currency_text = currency.text
    currency.click()
    time.sleep(1)
    # by_id = driver.find_element_by_class_name('tbtj2018_span')
    # name = by_id.find_elements_by_tag_name('span')
    # tbody = driver.find_element_by_class_name('tbtj2020_tab').is_displayed()
    # tbody = driver.find_elements_by_xpath("//*[@class='tbtj2020_tab']")
    tbody = driver.find_elements_by_class_name('tbtj2020_tab')[1]#.find_element_by_xpath("//*[@style='display:none']")
    # tbody = tbody1.find_element_by_tag_name('tbody')
    trs = tbody.find_elements_by_tag_name("tr")
    for tr in trs:
        tds = tr.find_elements_by_tag_name("td")
        for td in tds:
            print(td.text)
    # print(len(tbody))
    # name[1].click()
    # print(str(name[1].text).replace(' ', ''))
    # driver.close()



if __name__ == '__main__': #当程序执行时调用函数
    main()
